package com.gitee.sop.layui.adminserver.module.background.admin.manager;

import com.gitee.sop.layui.adminserver.module.background.admin.mapper.SysUserMenuRoleRelationMapper;
import com.gitee.sop.layui.adminserver.plugins.cache.util.CacheUtil;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Set;

/**
 * @author: huwei
 * @date: 2020/6/4 15:26
 * @version: 1.0.0
 */
@Component
public class SysUserMenuRoleRelationManager {
    @Lazy
    @Resource
    private SysUserMenuRoleRelationMapper sysUserMenuRoleRelationMapper;

    public Set<String> getMenuUrlListByUserUuid(String appId, String userUuid) {
        return CacheUtil.getOrPutIfAbsent(appId + ":" + userUuid, () -> this.sysUserMenuRoleRelationMapper.selectMenuUrlListByUserUuid(appId, userUuid), this.getClass().getName());
    }

    public void clearCache() {
        CacheUtil.clearDomain(this.getClass().getName());
    }
}
